<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.lable.profileAuditStd"/>（中心端）</title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <style type="text/css">
        #shclNs {
           position:fixed;
           left:0px;
           top:0px;
           width:100%;
           height:100%;
           opacity:0.75;
           -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=75)";
           filter:alpha(opacity=75);
           background-color: gray;
           margin:0px;
           padding:0px;
           z-index:999999;
           background:url('${ctx}/lib/img/loading.gif') no-repeat center center;
        }
    </style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame" style="height:100%;">
    
    <section class="content-header">
        <h1><spring:message code="message.lable.profileAuditStd"/></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.StdManage"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.compprofileStd"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.profileAuditStd"/></a></li>
        </ol>
    </section>
    
    <section class="content" style="min-height:0px;">
        <div class="box box-success">
            <div class="box-body">
                <div class="input">
                        <div class="textalign1"><spring:message code="message.listForm.ziZhiMingCheng"/><spring:message code="message.yanZheng.maoHao"/></div>
                        <div class="boxinput">
                        <input type="text" class="textinput"  id="searchProfileName" type="text" placeholder="<spring:message code="message.listForm.ziZhiMingCheng"/>" />
                    </div>
                        <div class="textalign"><spring:message code="message.listForm.ZiZhiBianMa"/><spring:message code="message.yanZheng.maoHao"/></div>
                        <div class="boxinput">
                        <input type="text" class="textinput"  id="searchProfileCode" type="text" placeholder="<spring:message code="message.listForm.ZiZhiBianMa"/>" />
                    </div>
                    <div class="textalign" >
                    <button id="selectAudit" type="button" onclick="searchDrugProfile();" class="btn btn-success btn-sm"><spring:message code="message.button.seachSpacing"/></button>
                </div>
            </div>
        </div>
        </div>
    </section>
    
    <section id="listPanel" class="content" style="min-height:0px;padding-top:0px;">
        <div id="scrollPanel" class="box box-primary" style="height:100%;overflow-y:auto;">
            <div id="wrapper" style="overflow:hidden;">
                <div id="content" style="overflow:hidden;"></div>
            </div>
        </div>
    </section>
    
    <section class="content-header" style="position:fixed;bottom:0px;left:0px;right:0px;">
        <div class=" box box-warning bottongroup">
            <a href="javascript:history.go(-1)" class="btn btn-default btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
        </div>
    </section>
    
    <div id="shclNs"></div>
    
    <script id="test" type="text/html">
        {{each rows as row i}}
            <div class="col-xs-6 col-lg-4 hei" style="height:500px;">
                <div class="wrapper2 ">
                    <a id=""  href="javascript:showImg('{{row.profilePicAddr}}','{{row.profileName}}');" ><img class="img-responsive" border="0" src="${ctx}/{{row.profilePicShortcutAddr}}" onerror="this.src='${ctx}/upload/image/nothing.jpg'" /></a>
                    <div class="row" style=" margin-left: -12;margin-left: -23px;" >
                        <div class="col-md-12">
                            <p class="pull-left imgButton">
                                <ms:btn url="/compProfile/approve.html"><button type="button" class="btn btn-primary btn-sm" style="margin-left: 1px;" onclick="approve('{{row.compprofileId}}');" style="margin-left:10px"><spring:message code="message.button.auditOK"/></button></ms:btn>
                                <ms:btn url="/compProfile/unapprove.html"><button type="button" class="btn btn-primary btn-sm" onclick="unapprove('{{row.compprofileId}}');"><spring:message code="message.button.auditNO"/></button></ms:btn>
                            </p>
                        </div>
                    </div>
                    <div class="row" style="margin-left:0px">
                        <div class="col-md-12">
                            <p class="pull-left">
                                <div class="productInfo" >&nbsp;<spring:message code="message.listForm.bianHao"/>:<span class="productInfo" name="profileCode" >{{row.profileCode}}</span></div>
                            </p>
                        </div>
                    </div>
                    <div class="row"  style="margin-left:0px">
                        <div class="col-md-12">
                            <p class="pull-left">
                                <div class="productInfo" >&nbsp;<spring:message code="message.listForm.mingCheng"/>:<span class="productInfo" name="profileName" >{{row.profileName}}</span></div>
                            </p>
                        </div>
                    </div>
                    <div class="row"  style="margin-left:0px">
                        <div class="col-md-12">
                            <p class="pull-left">
                                <div class="productInfo" >&nbsp;<spring:message code="message.lable.type"/>:<span class="productInfo" name="profileType" >{{row.firstLevelIndiName}}</span></div>
                            </p>
                        </div>
                    </div>
                    <div class="row"  style="margin-left:0px">
                        <div class="col-md-12">
                            <p class="pull-left">
                                 <div class="productInfo" >&nbsp;<spring:message code="message.listForm.youXiaoQi"/>:<span class="productInfo" name="profileTime" >&nbsp;{{row.profileStarttime}}&nbsp;&nbsp;<spring:message code="message.listForm.zhi"/>&nbsp;&nbsp;{{row.profileEndtime}}</span></div>
                            </p>
                        </div>
                    </div>
                    <div class="row"  style="margin-left:0px">
                        <div class="col-md-12">
                            <p class="pull-left">
                                <div class="productInfo" >&nbsp;<spring:message code="message.lable.status"/>:<span class="productInfo" name="status" >{{row.status | formatStatus}}</span></div>
                            </p>
                        </div>
                    </div>
                    <div class="row"  style="margin-left:0px">
                        <div class="col-md-12">
                            <p class="pull-left">
                                <div class="productInfo" >&nbsp;<spring:message code="message.lable.remark"/>:<span class="productInfo" name="remarks" >{{row.remarks}}</span></div>
                            </p>
                        </div>
                    </div>
                    <div class="row"  style="margin-left:0px">
                        <div class="col-md-12">
                            <p class="pull-left">
                                <div class="productInfo" >&nbsp;<spring:message code="message.listForm.shenHeBeiZhu"/>:</div>
                            </p>
                        </div>
                    </div>
                    <div class="row"  style="margin-left:0px">
                        <div class="col-md-12">
                            <p class="pull-left">
                                <div class="productInfo" >&nbsp;<textarea id="{{row.compprofileId}}" maxlength="500" rows="2" style="width:90%;"></textarea></div>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        {{/each}}
    </script>

    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
    
  //绑定回车
    $('#searchProfileCode,#searchProfileName').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#selectAudit').click();
        }
    }); 
  
    $("#searchProfileName").focus();//加载页面光标在第一个查询框内
    
        var records = 0;//总条目
        var postData = {"rows":6,"page":1,"compId":"${compId}"};//rows 一页展示多少条   page当前页数
    
        function resizeListHeight() {
            var windowHeight = $(window).height() || 0;
            var topHeight = $("#listPanel").position().top || 0;
            var bottomHeight = 75;
            var height = windowHeight - topHeight - bottomHeight;
            height = height < 0 ? 0 : height;
            $("#listPanel").height(height);
        }
        
        function getList(postData){
            $("#shclNs").show();
            $.post('${ctx}/compProfile/getCompProfileAuditList.html', postData, function(result) {
                if (result.success) {
                    $("#shclNs").hide();
                    var html = template('test', result);
                    $('#content').append(html);
                    records = result.records;  //总条数
                }
            }, "json");
        }
        
        function searchDrugProfile() {
            var profileCode = $.trim($("#searchProfileCode").val());
            var profileName = $.trim($("#searchProfileName").val());
            postData["profileCode"] = profileCode;
            postData["profileName"] = profileName;
            postData["page"] = 1;
            $('#content').children().remove();
            getList(postData);
        }
        
        // 审核通过
        function approve(compprofileId) {
            $.HN.message.confirm("<spring:message code="message.yanZheng.queDingShenHeTongGuoMa"/>", '', '').on(function (e) {
                 if (e) {
                    $.post("${ctx}/compProfile/approve.html", {
                        "compprofileId" : compprofileId
                    }, function(result) {
                        if (result.success) {
                        	searchDrugProfile();
                            $.alert("<spring:message code="message.HN.alert.shenHeTongGuoSuccess"/><spring:message code="message.yanZheng.ganTanHao"/>", "success");
                        } else {
                            $.alert("<spring:message code="message.HN.alert.shenHeTongGuoFail"/><spring:message code="message.yanZheng.ganTanHao"/>", "error");
                        }
                    }, "json");
                 }
             }); 
        }  
        
        // 审核不通过
        function unapprove(compprofileId) {
            var auditRemark = $.trim($("#" + compprofileId).val());
            
            if (auditRemark == null || auditRemark == "") {
                $.alert("<spring:message code="message.HN.alert.qingShuRuShenHeBeiZhu"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
                return;
            }
            
            $.HN.message.confirm("<spring:message code="message.HN.alert.queDingShenHeBuTongGuoMa"/><spring:message code="message.yanZheng.wenHao"/>", '', '').on(function (e) {
                 if (e) {
                    $.post("${ctx}/compProfile/unapprove.html", {
                        "compprofileId" : compprofileId,
                        "auditRemark" : auditRemark
                    }, function(result) {
                        if (result.success) {
                        	searchDrugProfile();
                            $.alert("<spring:message code="message.HN.alert.shenHeTongGuoSuccess"/><spring:message code="message.yanZheng.ganTanHao"/>", "success");
                        } else {
                            $.alert("<spring:message code="message.HN.alert.fail"/>", "error");
                        }
                    }, "json");
                 }
             }); 
        }  
        
        function showImg(imgPath, profileName) {
            var url = "${ctx}/acctInfo/toImg.html";
            $.HN.dialog.open({
                "id" : "showImg",
                "title" : profileName,
                "url" : url,
                "data" : {
                    "imgPath" : imgPath
                },
                "width" : 800,
                "height" : 400
            });
        }
    
        $(document).ready(function() {
            template.helper('formatStatus', function(data) {
                return data == 1 ? "<spring:message code="message.listForm.QiYong"/>" : "<spring:message code="message.listForm.TingYong"/>";
            });

            $(window).resize(function() {
                resizeListHeight();
            });
            
            var timer = null;
            
            $("#scrollPanel").scroll(function() {
                clearTimeout(timer);
                var scrollTop = $(this).scrollTop();
                var height = $("#wrapper").height() - $("#listPanel").height();
                timer = setTimeout(function() {
                    if (scrollTop >= height) {
                        postData.page++;
                        if (postData.page <= Math.ceil(records / postData.rows)) {
                            getList(postData);
                        } 
                    }
                }, 100);
            });
            
            resizeListHeight();
            getList(postData);
        });
    
        
    </script>

</body>
</html>

